# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and setting


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')

# See PyCharm help at https://www.jetbrains.com/help/pycharm/
import requests
from bs4 import BeautifulSoup

path = 'C:\\Users\\HP\\PycharmProjects\\pythonProject1\\sql_work.html'
fp = open(path, 'r', encoding='utf-8')
html = fp.read()
fp.close()
soup = BeautifulSoup(html, "html.parser")
html_h2 = soup.select('#page_content div h2')
html_div = soup.select('#page_content div')
html_tr = []
html_td = []
html_td1 = []
k = 0
for m in range(0, len(html_div), 3):
    html_tr = html_div[m].select('tr')
    html_td.append(html_h2[k].text)
    k = k+1
    html_td.append("(")
    for i in range(1, len(html_tr)+1):
        html_td1 = html_tr[i].select('td')
        if len(html_td1) == 0:
            break
        if i != 1:
            html_td.append(',')
        html_td.append(html_td1[0].text)
    html_td.append(")")
    html_td.append('\n')

fp = open('./workanswer', 'w', encoding='utf-8')
for i in html_td:
    fp.write(str(i))
fp.close()







